//
//  EmotionInputView.m
//  Project_2_weibo
//
//  Created by 林林 on 16/7/7.
//  Copyright © 2016年 lhn. All rights reserved.
//

#import "EmotionInputView.h"
#import "Emotion.h"

@interface EmotionInputView ()
{
    UIScrollView *_scrollView;
    UIPageControl *_pageControl;
    NSMutableArray *_emotions;
}
@end

@implementation EmotionInputView

- (instancetype)init
{
    self = [super init];
    if (self) {
        //设定frame
        self.frame = CGRectMake(0, 0, kScreenWidth, kEmotionInputViewHeight);
        self.backgroundColor = [UIColor blackColor];
        [self loadEmotionData];
        [self createScrollView];
        [self createPageControl];
    }
    return self;
}

- (void)createScrollView {
    
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kEmotionScrollViewHeight)];
    _scrollView.backgroundColor = [UIColor redColor];
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.showsVerticalScrollIndicator = NO;
    _scrollView.pagingEnabled = YES;
    [self addSubview:_scrollView];
    
    //创建滑动视图的内容视图 表情显示界面
    
    
}

- (void)createPageControl {
    
    _pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, kEmotionScrollViewHeight, kScreenWidth, kPageControlHeight)];
    [self addSubview:_pageControl];
    
    _pageControl.numberOfPages = 5;
    _pageControl.currentPage = 2;
}

- (void)loadEmotionData {
    
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"emoticons" ofType:@"plist"];
    //读取文件到数组
    NSArray *array = [[NSArray alloc] initWithContentsOfFile:filePath];
    _emotions = [NSMutableArray array];
    
    //遍历数组创建表情对象
    for (NSDictionary *dic in array) {
        Emotion *e = [Emotion yy_modelWithDictionary:dic];
        [_emotions addObject:e];
    }
    
}




@end




